package cn.outsourcing.supermarket.controller.backstage;

import cn.outsourcing.supermarket.common.Result;
import cn.outsourcing.supermarket.common.utils.ResultUtils;
import cn.outsourcing.supermarket.dto.OnlyIdPayloadDTO;
import cn.outsourcing.supermarket.dto.backstage.BackstageOnlyIdPageDTO;
import cn.outsourcing.supermarket.dto.backstage.BackstageUserListDTO;
import cn.outsourcing.supermarket.service.BackstageOrderService;
import cn.outsourcing.supermarket.service.BackstageUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author gzkemays
 * @since 2021/11/4 18:13
 */
@RestController
@RequestMapping("/admin/user")
public class UserController {
  @Resource BackstageUserService backstageUserService;
  @Resource BackstageOrderService backstageOrderService;

  @PostMapping("/updateInfo")
  public Result updateInfo(@RequestBody BackstageUserListDTO dto) {
    return ResultUtils.simpleResult(backstageUserService.updateInfo(dto));
  }

  @GetMapping("/info")
  public Result info(OnlyIdPayloadDTO dto) {
    return ResultUtils.simpleResult(backstageUserService.getUserInfo(dto));
  }

  @GetMapping("/order")
  public Result order(BackstageOnlyIdPageDTO dto) {
    return ResultUtils.simpleResult(backstageOrderService.userOrder(dto));
  }

  @GetMapping("/datainfo")
  public Result dataInfo(OnlyIdPayloadDTO dto) {
    return ResultUtils.simpleResult(backstageUserService.getUserDataInfo(dto));
  }

  @GetMapping("/cartdata")
  public Result cartData(BackstageOnlyIdPageDTO dto) {
    return ResultUtils.simpleResult(backstageUserService.getCartShop(dto));
  }

  @GetMapping("/foot")
  public Result foot(BackstageOnlyIdPageDTO dto) {
    return ResultUtils.simpleResult(backstageUserService.getFootPrint(dto));
  }
}
